<?php
set_include_path('system'.PATH_SEPARATOR.'templates');

require_once('Template.php');
require_once('RedirectBrowserException.php');
require_once('DatabaseUtility.php');

$tmpl = new Template();

openDatabase();

$query = "SELECT version FROM p3dbInfo";
$result = runQuery($query);
$version = $result[0]['version'];

$query ="SELECT COUNT(*) AS count FROM dataSource ORDER BY pubmed DESC;";
$result = runQuery($query);
$numref = $result[0]['count'];

$query = "SELECT COUNT(*) as count FROM protein;";
$result = runQuery($query);
$procount = number_format($result[0]['count']);

$query = "SELECT COUNT(*) as count FROM site WHERE site.ptm='p';";
$result = runQuery($query);
$sitecount = number_format($result[0]['count']);

$orgs = array();
$query ="SELECT label,latin FROM organism ORDER BY latin;";
$result = runQuery($query);
foreach($result as $row) {
	$orgs[$row['label']] = $row['latin'];
}

$news = array(
	'css/images/home1.jpg' => '<strong>Welcome to P<sup>3</sup>DB!</strong><br /><br />To start searching you can use the quick seach features at the top of this page or go to the search page in the menu bar.<br /><br />Use the quick search feature for a simple keyword search or go to the search page for more advanced search options including BLAST.<br /><br />Go to the data sets page for more details on the data stored in P<sup>3</sup>DB.',
	'css/images/home2.jpg' => 'This is a test2',
	'css/images/home3.jpg' => 'This is a test3',
);

$tmpl->news = $news;
$tmpl->version = $version;
$tmpl->numref = $numref;
$tmpl->procount = $procount;
$tmpl->sitecount = $sitecount;
$tmpl->orgs = $orgs;

closeDatabase();

$tmpl->current = 'home';
$tmpl->pageContent = $tmpl->build('home.tmpl');

print $tmpl->build('page.tmpl');
?>